<template>
  <!-- FBA货件明细-->
  <a-table style="margin-top: 10px" class="table-normal-line" :data="list" size="mini" :summary="true" :bordered="false" :pagination="false">
    <template #columns>
      <a-table-column data-index="img" title="图片" :width="60">
        <template #cell="{ record }">
          <ImgPopover :src="record.productImg">
            <template #con>
              <a-image width="40" height="40" fit="contain" :src="record.productImg" />
            </template>
          </ImgPopover>
        </template>
      </a-table-column>
      <a-table-column title="MSKU/ASIN" :width="100">
        <template #cell="{ record }">
          <TextLimit :rows="1">{{ record.msku }}</TextLimit>
          <TextLimit :rows="1">{{ record.asin }}</TextLimit>
        </template>
      </a-table-column>
      <a-table-column data-index="fnsku" title="FNSKU" :width="100" />
      <a-table-column data-index="sku" title="SKU" :width="100">
        <template #cell="{ record }">
          <ShowSpuDetailBySku :val="record.sku" :showLimit="false" :renderBody="false" />
        </template>
      </a-table-column>
      <template v-if="size != 'mini'">
        <a-table-column data-index="packageName" title="包装" :width="120" />
        <a-table-column data-index="salesmanName" title="销售员" :width="70" />
      </template>
      <a-table-column data-index="realNum" title="发货数" :width="60" />
      <template v-if="size != 'mini'">
        <template v-if="status == 'DRAFT'">
          <a-table-column data-index="productInventory" title="产品可用库存" :width="90">
            <template #cell="{ record }">
              <div class="flex-c-sb">
                <p>{{ record.productInventory }}</p>
                <p class="warningColor" v-if="record.realNum > record.productInventory">缺货</p>
              </div>
            </template>
          </a-table-column>
          <a-table-column data-index="realNum" title="包装数" :width="60" />
          <a-table-column data-index="packageInventory" title="包装可用库存" :width="90">
            <template #cell="{ record }">
              <div class="flex-c-sb">
                <p>{{ record.packageInventory }}</p>
                <p class="warningColor" v-if="record.marks && record.marks.includes('缺包装')">缺包装</p>
              </div>
            </template>
          </a-table-column>
        </template>
        <template v-else>
          <a-table-column data-index="receiveNum" title="入库数" :width="60" />
          <a-table-column data-index="diffNum" title="差异" :width="60">
            <template #cell="{ record }">
              <p>{{ Number(record.realNum || 0) - Number(record.receiveNum || 0) }}</p>
            </template>
          </a-table-column>
          <a-table-column data-index="shipFee" title="运费" :width="80">
            <template #cell="{ record }">
              <p>￥{{ record.shipFee }}</p>
            </template>
          </a-table-column>
          <a-table-column data-index="laborCost" title="处理费" :width="80">
            <template #cell="{ record }">
              <p>￥{{ record.laborCost }}</p>
            </template>
          </a-table-column>
          <a-table-column data-index="price" title="单价" :width="80">
            <template #cell="{ record }">
              <p>￥{{ record.price }}</p>
            </template>
          </a-table-column>
          <a-table-column data-index="productValue" title="货值" :width="80">
            <template #cell="{ record }">
              <p>￥{{ record.productValue }}</p>
            </template>
          </a-table-column>
          <a-table-column data-index="receiveValue" title="入库货值" :width="80">
            <template #cell="{ record }">
              <p>￥{{ record.receiveValue }}</p>
            </template>
          </a-table-column>
        </template>
      </template>
    </template>
    <template #summary-cell="{ column, record }">
      <p v-if="column.dataIndex == 'sku'">合计</p>
      <p v-else-if="['realNum', 'receiveNum', 'productInventory', 'packageInventory'].includes(column.dataIndex)">{{ record[column.dataIndex] }}</p>
      <p v-else-if="['shipFee', 'laborCost', 'productValue', 'receiveValue'].includes(column.dataIndex)">￥{{ record[column.dataIndex].toFixed(4) }}</p>
      <p v-else-if="['diffNum'].includes(column.dataIndex)">{{ Number(record.realNum || 0) - Number(record.receiveNum || 0) }}</p>
    </template>
  </a-table>
</template>
<script lang="ts" setup>
  import { PropType } from 'vue'
  const props = defineProps({
    isShow: {
      type: Boolean,
      default: false,
    },
    list: {
      type: Array as PropType<Array<any>>,
      default: () => [],
    },
    size: {
      type: String,
    },
    status: {
      type: String,
    },
  })
</script>
<style lang="less" scoped></style>
